package gui;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;

/**
 * COPYRIGHT (C) 2009. Denny Tran, Omar Jaime, David Deng, Julie Hsieh. All Rights Reserved
 * Class is a ViewPanel containing JComponents displaying document information.  
 * @author Denny Tran, Omar Jaime, David Deng, Julie Hsieh 
 * @version 1.01 2009-05-05
 */

public class DocumentPanel extends ViewPanel
{   
	private DefaultListModel listModel;
	private JList list;
	private JScrollPane scroll;
    
	/**
     * Construct ViewPanel containing JComponents asking for document information
     * @param viewManager the container of this panel
     * @param identification specific identification used to reference this panel
     */
    public DocumentPanel(ViewManager viewManager, String identification)
    {
        super(viewManager, identification);
        
        JLabel title = new JLabel("Documents");
        title.setFont(new Font("Serif", Font.PLAIN, 24));
        title.setSize(150, 20);
        title.setLocation(60, 0);
        this.add(title);
        
        listModel = new DefaultListModel();
		list = new JList(listModel);
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		list.setLayoutOrientation(JList.VERTICAL);
		scroll = new JScrollPane(list);
		scroll.setLocation(50, 70);
		scroll.setSize(300, 200);
		//intialize existing group members
		listModel.addElement("SRS specifications");
		listModel.addElement("SDS specifications");
		this.add(scroll);
        
        JButton addDocumentButton = new JButton("Add Document");
        addDocumentButton.setSize(200,20);
        addDocumentButton.setLocation(30,450);
        addDocumentButton.addActionListener(viewManager.addLink("add document"));
        this.add(addDocumentButton);
    }
    
    /**
     * Paints graphical aspects of the panel
     *@param g the graphical component used to paint the panel 
     */
    public void paintComponent(Graphics g)
    {
    	super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        
        g2.drawString("Document Name", 50, 50);
        //g2.drawString("Events Attached", 400, 50);
    }
    
    /**
     * Adds a document name to the JList
     * @param doc the document name
     * @param adress the address of the document
     */
    public void addDocument(String doc, String adress)
    {
    	listModel.addElement(doc);
    	repaint();
    }

    /**
     * Clears all text fields and check boxes
     */
	public void clearView()
	{
		// TODO Auto-generated method stub
		
	}
}
